home *** CD-ROM | disk | FTP | other *** search
- function point(x, y)
- {
- this.x = x;
- this.y = y;
- }
- function Forecourt()
- {
- var _loc1_ = this;
- _loc1_.openPumps = 0;
- _loc1_.pSpaces = new Array(-1,-1,-1,-1,-1,-1);
- _loc1_.pCars = new Array();
- _loc1_.pTimer = 0;
- _loc1_.pTimeGap = 160;
- _loc1_.pCarCount = 1;
- _loc1_.addPumps(2);
- }
- function Stelios(x, y, pos)
- {
- var _loc1_ = this;
- _loc1_.pPosX = x;
- _loc1_.pPosY = y;
- _loc1_.pSpeedX = 0;
- _loc1_.pSpeedY = 0;
- _loc1_.pDistCount = 0;
- _loc1_.pSpeed = 10;
- _loc1_.pDistX = 200 / _loc1_.pSpeed;
- _loc1_.pDistY = 100 / _loc1_.pSpeed;
- _loc1_.pPosition = pos;
- _loc1_.pMoving = false;
- _loc1_.pDodge = false;
- _loc1_.pDodgeFlag = false;
- _loc1_.p_mc = objects_mc.attachMovie("mc.stelios","stelios_mc",200);
- _loc1_.p_mc._x = _loc1_.pPosX;
- _loc1_.p_mc._y = _loc1_.pPosY;
- }
- function car(tNum, tSpace, tOwner)
- {
- var _loc1_ = this;
- var _loc2_ = tSpace;
- var _loc3_ = tNum;
- _loc1_.pLane = 1;
- _loc1_.pSpace = _loc2_;
- switch(_loc2_)
- {
- case 0:
- case 1:
- case 2:
- _loc1_.pLane = 0;
- break;
- case 3:
- case 4:
- case 5:
- _loc1_.pLane = 2;
- _loc2_ -= 3;
- }
- _loc1_.pOwner = tOwner;
- _loc1_.pId = _loc3_;
- _loc1_.pPos = -50;
- _loc1_.pSpeed = 0;
- _loc1_.pMaxSpeed = 10;
- _loc1_.pDestination = 160 + _loc2_ * 200;
- _loc1_.pState = 0;
- _loc1_.pAniState = "moving";
- _loc1_.waitCount = 100;
- _loc1_.p_mc = objects_mc.attachMovie("mc.car" + Math.round(1 + Math.random() * 4),"car" + _loc3_,5 + _loc1_.pLane * 100 + _loc3_);
- _loc1_.p_mc._x = _loc1_.pPos;
- _loc1_.p_mc._y = _loc1_.pLane * 72 + 197;
- _loc1_.nextState();
- }
- Math.randomInt = function(aLo, aHi)
- {
- return aLo + Math.round(Math.random() * (aHi - aLo));
- };
- point.prototype.rotate = function(tAngle)
- {
- var _loc1_ = tAngle / 180 * 3.141592653589793;
- var _loc2_ = [[Math.cos(_loc1_),Math.sin(_loc1_)],[- Math.sin(_loc1_),Math.cos(_loc1_)]];
- var tX = this.x;
- var _loc3_ = this.y;
- this.x = tX * _loc2_[0][0] + _loc3_ * _loc2_[1][0];
- this.y = tX * _loc2_[0][1] + _loc3_ * _loc2_[1][1];
- };
- point.prototype.randomDir = function(tCap)
- {
- this.x *= Math.round(Math.random()) * 2 - 1;
- this.y *= Math.round(Math.random()) * 2 - 1;
- };
- point.prototype.capLength = function(tCap)
- {
- var _loc1_ = this;
- var _loc3_ = tCap;
- var _loc2_ = Math.sqrt(_loc1_.x * _loc1_.x + _loc1_.y * _loc1_.y);
- if(_loc2_ > _loc3_)
- {
- _loc1_.x /= _loc2_;
- _loc1_.y /= _loc2_;
- _loc1_.x *= _loc3_;
- _loc1_.y *= _loc3_;
- }
- };
- Forecourt.prototype.addPumps = function(tOpen)
- {
- var _loc1_ = this;
- if(_loc1_.openPumps < tOpen)
- {
- switch(tOpen)
- {
- case 2:
- _loc1_.pSpaces[2] = 0;
- _loc1_.pSpaces[5] = 0;
- pump3_mc.openPump();
- pump6_mc.openPump();
- _loc1_.openPumps += 2;
- break;
- case 3:
- _loc1_.pSpaces[1] = 0;
- pump2_mc.openPump();
- _loc1_.openPumps += 1;
- break;
- case 4:
- _loc1_.pSpaces[4] = 0;
- pump5_mc.openPump();
- _loc1_.openPumps += 1;
- break;
- case 5:
- _loc1_.pSpaces[0] = 0;
- pump1_mc.openPump();
- _loc1_.openPumps += 1;
- break;
- case 6:
- _loc1_.pSpaces[3] = 0;
- pump4_mc.openPump();
- _loc1_.openPumps += 1;
- }
- }
- };
- Forecourt.prototype.getOpenPump = function()
- {
- var tFreePumps = new Array();
- var _loc2_ = 0;
- while(_loc2_ < 2)
- {
- var _loc1_ = 0;
- while(_loc1_ < 3)
- {
- var _loc3_ = this.pSpaces[_loc2_ * 3 + _loc1_];
- if(_loc3_ == 1)
- {
- break;
- }
- if(_loc3_ == 0)
- {
- tFreePumps[_loc2_] = _loc2_ * 3 + _loc1_;
- }
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(tFreePumps[0] == undefined)
- {
- tFreePumps.splice(0,1);
- }
- else if(tFreePumps[1] == undefined)
- {
- tFreePumps.splice(1,1);
- }
- var tItem;
- var tCount = tFreePumps.length;
- if(tCount == 0)
- {
- return 6;
- }
- if(tCount == 1)
- {
- tItem = tFreePumps[0];
- }
- else
- {
- tItem = tFreePumps[Math.round(Math.random())];
- }
- this.pSpaces[tItem] = 1;
- return tItem;
- };
- Forecourt.prototype.update = function()
- {
- var _loc2_ = this;
- var _loc3_ = _loc2_.pCars.length;
- var _loc1_ = _loc3_ - 1;
- while(_loc1_ > -1)
- {
- if(!_loc2_.pCars[_loc1_].update())
- {
- _loc2_.pCars[_loc1_].kill();
- _loc2_.pCars.splice(_loc1_,1);
- }
- _loc1_ = _loc1_ - 1;
- }
- if(--_loc2_.pTimer <= 0)
- {
- _loc2_.pTimeGap = Math.max(_loc2_.pTimeGap - 5,100);
- _loc2_.pTimer = Math.randomInt(0,24) + _loc2_.pTimeGap;
- _loc2_.pCars.push(new car(_loc2_.pCarCount++,_loc2_.getOpenPump(),_loc2_));
- if(_loc2_.pCarCount >= 50)
- {
- _loc2_.pCarCount = 1;
- }
- else if(_loc2_.pCarCount >= 26)
- {
- _loc2_.addPumps(6);
- }
- else if(_loc2_.pCarCount >= 17)
- {
- _loc2_.addPumps(5);
- }
- else if(_loc2_.pCarCount >= 11)
- {
- _loc2_.addPumps(4);
- }
- else if(_loc2_.pCarCount >= 4)
- {
- _loc2_.addPumps(3);
- }
- }
- };
- Forecourt.prototype.safeToMove = function(tLane, tPos)
- {
- var _loc2_ = tPos;
- var _loc3_ = undefined;
- var _loc1_ = undefined;
- for(_loc3_ in this.pCars)
- {
- _loc1_ = this.pCars[_loc3_];
- if(_loc1_.checkLane(tLane))
- {
- _loc2_ = Math.min(_loc2_,_loc1_.getBumperPos(_loc2_));
- }
- }
- return _loc2_;
- };
- Forecourt.prototype.leavingSpace = function(tSpace)
- {
- this.pSpaces[tSpace] = 0;
- };
- Forecourt.prototype.pumpDone = function(tPumpNum)
- {
- var _loc3_ = this;
- var _loc2_ = _loc3_.pCars.length;
- var _loc1_ = 0;
- while(_loc1_ < _loc2_)
- {
- _loc3_.pCars[_loc1_].leavePump(tPumpNum);
- _loc1_ = _loc1_ + 1;
- }
- };
- Forecourt.prototype.pumpStarted = function(tPumpNum)
- {
- var _loc3_ = this;
- var _loc2_ = _loc3_.pCars.length;
- var _loc1_ = 0;
- while(_loc1_ < _loc2_)
- {
- _loc3_.pCars[_loc1_].fillingUp(tPumpNum);
- _loc1_ = _loc1_ + 1;
- }
- };
- Stelios.prototype.showLose = function()
- {
- this.p_mc.gotoAndPlay("lose");
- };
- Stelios.prototype.flyAway = function()
- {
- this.p_mc.gotoAndPlay("fly");
- };
- Stelios.prototype.showWin = function()
- {
- this.p_mc.gotoAndPlay("wave");
- };
- Stelios.prototype.checkPos = function()
- {
- var _loc1_ = this;
- if(_loc1_.pPosition > 6)
- {
- return _loc1_.pPosition - 4;
- }
- if(_loc1_.pPosition < 4)
- {
- return _loc1_.pPosition - 1;
- }
- return -1;
- };
- Stelios.prototype.checkCar = function(tX, tY)
- {
- var _loc1_ = this;
- var _loc3_ = Math.ceil(_loc1_.pPosition / 3) - 1;
- if(!_loc1_.pMoving)
- {
- if(_loc3_ != 1)
- {
- return false;
- }
- }
- var tOffsetX = _loc1_.pPosX - tX;
- var _loc2_ = _loc1_.pPosY - tY;
- if(Math.abs(tOffsetX) < 70)
- {
- if(Math.abs(_loc2_) < 15)
- {
- if(_loc1_.pSpeedX + _loc1_.pSpeedY == 0)
- {
- _loc1_.pDodge = true;
- if(_loc1_.pPosY == _loc1_.p_mc._y)
- {
- _loc1_.pDodgeFlag = true;
- _loc1_.p_mc._y -= 40;
- _loc1_.p_mc.swapDepths(100);
- _loc1_.p_mc.gotoAndPlay("pauseDown");
- }
- }
- else if(_loc1_.pSpeedX != 0)
- {
- _loc1_.pDodge = true;
- if(_loc1_.pPosY == _loc1_.p_mc._y)
- {
- _loc1_.pDodgeFlag = true;
- _loc1_.p_mc._y -= 40;
- _loc1_.p_mc.swapDepths(100);
- _loc1_.p_mc.gotoAndPlay("pauseDown");
- }
- }
- else
- {
- _loc1_.pDodge = true;
- if(_loc1_.pPosY == _loc1_.p_mc._y)
- {
- _loc1_.pDodgeFlag = true;
- if(_loc1_.pSpeedY == 1)
- {
- if(_loc2_ > 0)
- {
- _loc1_.p_mc._y += 40;
- _loc1_.pDistCount -= 4;
- if(_loc1_.pDistCount < 0)
- {
- _loc1_.pDistCount = 4;
- _loc1_.pSpeedY *= -1;
- }
- _loc1_.p_mc.gotoAndPlay("pauseUp");
- switch(_loc3_)
- {
- case 0:
- _loc1_.p_mc.swapDepths(100);
- break;
- case 1:
- _loc1_.p_mc.swapDepths(300);
- }
- }
- else
- {
- _loc1_.p_mc._y -= 40;
- _loc1_.pDistCount += 4;
- _loc1_.p_mc.gotoAndPlay("pauseDown");
- }
- }
- else if(_loc2_ > 0)
- {
- _loc1_.p_mc._y += 40;
- _loc1_.pDistCount += 4;
- _loc1_.p_mc.gotoAndPlay("pauseUp");
- }
- else
- {
- _loc1_.p_mc._y -= 40;
- _loc1_.pDistCount -= 4;
- _loc1_.p_mc.gotoAndPlay("pauseDown");
- switch(_loc3_)
- {
- case 1:
- _loc1_.p_mc.swapDepths(0);
- break;
- case 2:
- _loc1_.p_mc.swapDepths(200);
- }
- }
- }
- }
- }
- }
- };
- Stelios.prototype.update = function()
- {
- if(this.pDodge)
- {
- this.pDodge = false;
- }
- else
- {
- if(!this.pMoving)
- {
- this.pSpeedX = 0;
- this.pSpeedY = 0;
- if(Key.isDown(37))
- {
- if(this.pPosition == 5 || this.pPosition == 6)
- {
- this.pSpeedX = -1;
- this.pDistCount = this.pDistX;
- this.p_mc.gotoAndPlay("walkLeft");
- }
- }
- else if(Key.isDown(39))
- {
- if(this.pPosition == 4 || this.pPosition == 5)
- {
- this.pSpeedX = 1;
- this.pDistCount = this.pDistX;
- this.p_mc.gotoAndPlay("walkRight");
- }
- }
- else if(Key.isDown(38))
- {
- if(this.pPosition == 4 || this.pPosition == 5 || this.pPosition == 6 || this.pPosition == 7 || this.pPosition == 8 || this.pPosition == 9)
- {
- this.pSpeedY = -1;
- this.pDistCount = this.pDistY;
- this.p_mc.gotoAndPlay("walkUp");
- }
- }
- else if(Key.isDown(40))
- {
- if(this.pPosition == 1 || this.pPosition == 2 || this.pPosition == 3 || this.pPosition == 4 || this.pPosition == 5 || this.pPosition == 6)
- {
- this.pSpeedY = 1;
- this.pDistCount = this.pDistY;
- this.p_mc.gotoAndPlay("walkDown");
- }
- }
- if(this.pSpeedX + this.pSpeedY != 0)
- {
- if(this.pPosition > 6)
- {
- eval("pump" + (this.pPosition - 3) + "_mc").leftPump();
- }
- else if(this.pPosition < 4)
- {
- eval("pump" + this.pPosition + "_mc").leftPump();
- }
- this.pMoving = true;
- }
- else if(this.pDodgeFlag)
- {
- this.pDodgeFlag = false;
- this.p_mc.gotoAndPlay("stand");
- }
- }
- else
- {
- if(this.pDodgeFlag)
- {
- this.pDodgeFlag = false;
- if(this.pSpeedY != 0)
- {
- this.pPosY = this.p_mc._y;
- }
- if(this.pSpeedX == -1)
- {
- this.p_mc.gotoAndPlay("walkLeft");
- }
- else if(this.pSpeedX == 1)
- {
- this.p_mc.gotoAndPlay("walkRight");
- }
- else if(this.pSpeedY == -1)
- {
- this.p_mc.gotoAndPlay("walkUp");
- }
- else
- {
- this.p_mc.gotoAndPlay("walkDown");
- }
- }
- this.pMoving = --this.pDistCount > 0;
- if(!this.pMoving)
- {
- this.p_mc.gotoAndPlay("stand");
- if(this.pPosY > 320)
- {
- this.pSpeedY = 1;
- }
- this.pPosition += this.pSpeedX + this.pSpeedY * 3;
- if(this.pPosition > 6)
- {
- eval("pump" + (this.pPosition - 3) + "_mc").checkPumpStelios();
- this.p_mc.swapDepths(300);
- }
- else if(this.pPosition < 4)
- {
- eval("pump" + this.pPosition + "_mc").checkPumpStelios();
- this.p_mc.swapDepths(0);
- }
- else
- {
- this.p_mc.swapDepths(200);
- }
- this.pSpeedX = 0;
- this.pSpeedY = 0;
- }
- }
- this.p_mc._x = this.pPosX += this.pSpeedX * this.pSpeed;
- this.p_mc._y = this.pPosY += this.pSpeedY * this.pSpeed;
- }
- };
- car.prototype.nextState = function()
- {
- this.pState = this.pState + 1;
- switch(this.pState)
- {
- case 1:
- this.pAniState = "moving";
- this.p_mc.gotoAndPlay(this.pAniState);
- break;
- case 2:
- this.pAniState = "fuelling";
- this.waitCount = 72;
- this.p_mc.gotoAndPlay(this.pAniState);
- eval("pump" + (this.pSpace + 1) + "_mc").checkPumpCar();
- break;
- case 3:
- this.waitCount = 120;
- eval("pump" + (this.pSpace + 1) + "_mc").angryCar();
- break;
- case 4:
- break;
- case 5:
- eval("pump" + (this.pSpace + 1) + "_mc").leavingPump();
- this.pAniState = "leave_happy";
- this.p_mc.gotoAndPlay(this.pAniState);
- break;
- case 6:
- this.kill();
- }
- };
- car.prototype.update = function()
- {
- var _loc1_ = this;
- switch(_loc1_.pState)
- {
- case 0:
- break;
- case 1:
- _loc1_.pSpeed = Math.min((_loc1_.pDestination - _loc1_.pPos) / 10,_loc1_.pMaxSpeed);
- if(_loc1_.pSpeed < _loc1_.pMaxSpeed)
- {
- if(_loc1_.pAniState == "moving")
- {
- _loc1_.pAniState = "stopping";
- _loc1_.p_mc.gotoAndPlay(_loc1_.pAniState);
- }
- }
- if(_loc1_.pSpeed < 1)
- {
- _loc1_.nextState();
- }
- _loc1_.pPos += _loc1_.pSpeed;
- var _loc2_ = _loc1_.pOwner.safeToMove(_loc1_.pLane,_loc1_.pPos);
- if(_loc2_ != _loc1_.pPos)
- {
- _loc1_.pPos = _loc2_;
- }
- _loc1_.p_mc._x = _loc1_.pPos;
- pStelios.checkCar(_loc1_.p_mc._x,_loc1_.p_mc._y);
- if(_loc1_.pPos > 700)
- {
- _loc1_.kill();
- return false;
- }
- break;
- case 2:
- _loc1_.waitCount = _loc0_ = _loc1_.waitCount - 1;
- if(_loc0_ <= 0)
- {
- _loc1_.nextState();
- }
- break;
- case 3:
- _loc1_.waitCount = _loc0_ = _loc1_.waitCount - 1;
- if(_loc0_ <= 0)
- {
- scores_mc.addpoints(-1000);
- _loc1_.pOwner.leavingSpace(_loc1_.pSpace);
- _loc1_.pState = 4;
- _loc1_.nextState();
- }
- break;
- case 4:
- break;
- case 5:
- _loc1_.pSpeed = Math.min(10,_loc1_.pSpeed * 1.1);
- _loc1_.pPos += _loc1_.pSpeed;
- _loc2_ = _loc1_.pOwner.safeToMove(_loc1_.pLane,_loc1_.pPos);
- if(_loc2_ != _loc1_.pPos)
- {
- _loc1_.pPos = _loc2_;
- }
- _loc1_.p_mc._x = _loc1_.pPos;
- _loc1_.pSpace = 6;
- if(_loc1_.pPos > 700)
- {
- return false;
- }
- break;
- }
- return true;
- };
- car.prototype.getBumperPos = function(tPos)
- {
- if(tPos < this.pPos)
- {
- return this.pPos - 160;
- }
- return tPos;
- };
- car.prototype.leavePump = function(tPumpNum)
- {
- var _loc1_ = this;
- if(_loc1_.pState == 4)
- {
- if(tPumpNum == _loc1_.pSpace + 1)
- {
- scores_mc.addpoints(1000);
- _loc1_.nextState();
- }
- }
- };
- car.prototype.fillingUp = function(tPumpNum)
- {
- var _loc1_ = this;
- if(tPumpNum == _loc1_.pSpace + 1)
- {
- if(_loc1_.pState == 2)
- {
- _loc1_.pState = 3;
- _loc1_.nextState();
- }
- else if(_loc1_.pState == 3)
- {
- _loc1_.nextState();
- }
- }
- };
- car.prototype.checkLane = function(tLane)
- {
- return tLane == this.pLane;
- };
- car.prototype.kill = function()
- {
- var _loc1_ = this;
- delete _loc1_.pId;
- delete _loc1_.pPos;
- delete _loc1_.pSpeed;
- delete _loc1_.pMaxSpeed;
- delete _loc1_.pDestination;
- delete _loc1_.pState;
- delete _loc1_.pAniState;
- delete _loc1_.pOwner;
- delete _loc1_.pSpace;
- _loc1_.p_mc.removeMovieClip();
- };
- this.pLives = 3;
- this.lives_mc.setTo(this.pLives * 22);
- this.pForeCourt = new Forecourt();
- this.pStelios = new Stelios(455,260,6);
- this.gameOver = function()
- {
- var _loc2_ = this;
- var _loc1_ = 1;
- while(_loc1_ < 7)
- {
- _loc2_["pump" + _loc1_ + "_mc"].gameover();
- _loc1_ = _loc1_ + 1;
- }
- _loc2_.play();
- };
- this.onEnterFrame = function()
- {
- this.pForeCourt.update();
- this.pStelios.update();
- };
- stop();
-